﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dali.Address;

namespace Dali.Command
{
  [Serializable]
  public abstract class DaliCommand
  {

    public DaliCommand()
    {
     
    }

    public virtual byte[] GetHidCommand()
    {
      byte[] hidCommand;

      hidCommand = new byte[65];
      hidCommand[0] = 0x00;
      hidCommand[1] = 0x10;
      hidCommand[2] = 0x83;
      hidCommand[8] = 0x02;

      hidCommand[5] = this.Address.Address;
      hidCommand[5] <<= 1;
      hidCommand[5] |= 0x01;

      if (this.Address is GroupAddress)
      {
        hidCommand[5] |= 0x80;
      }

      return hidCommand;
    }
    
    public DaliAddress Address
    {
      get;
      set;
    }

    //public virtual byte Address
    //{
    //  get
    //  {
    //    return (byte)(this.hidCommand[5] >> 1);
    //  }

    //  set
    //  {
    //    this.hidCommand[5] = (byte)(value << 1);
    //    this.HidCommand[5] |= 0x01;
    //  }
    //}
    

  }
}
